{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">友情链接列表</div>
    <div class="layui-card-body">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this"><a href="{:url('index')}">友情链接列表</a></li>
                <li><a href="{:url('terms')}">分类列表</a></li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="type">
    {{# if(d.linktype ==0){ }}
  文字链接
  {{#  } else { }}
  图片链接
  {{#  } }}
</script>
<script type="text/html" id="image">
    {{# if(d.image ==0){ }}
  无
  {{#  } else { }}
  有
  {{#  } }}

</script>
<script type="text/html" id="barTool">
    <a data-open='{:url("edit")}?id={{ d.id }}' data-full="true" class="layui-btn layui-btn-xs">编辑</a>
    <a href='{:url("del")}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
</script>
<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" value="{{d.id}}" data-href="{:url('multi')}?id={{d.id}}&param=status" lay-skin="switch" lay-text="已通过|未通过" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        add_url: "{:url('add')}",
        delete_url: "{:url('del')}",
        modify_url: '{:url("multi")}',
    };

    table.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        toolbar: ['refresh',
            [{
                text: '添加',
                url: init.add_url,
                method: 'open',
                class: 'layui-btn layui-btn-normal layui-btn-sm',
                icon: 'iconfont icon-add',
                extend: 'data-full="true"',
            }], 'delete'
        ],
        url: '{:url("index")}',
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'listorder', width: 70, title: '排序', edit: 'text' },
                { field: 'id', width: 70, title: 'ID' },
                { field: 'name', title: '网站名称' },
                { field: 'url', title: '网站网址' },
                { field: 'image', width: 150, title: '网站LOGO', templet: '#image', selectList: { 0: '无', 1: '有' } },
                { field: 'linktype', width: 150, title: '链接类型', templet: '#type', selectList: { 0: '文字链接', 1: '图片链接' } },
                { field: 'termsid', width: 80, title: '分类ID' },
                { field: 'inputtime', width: 180, title: '添加时间', search: 'range' },
                { field: 'status', width: 120, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '未通过', 1: '已通过' } },
                { fixed: 'right', width: 150, title: '操作', toolbar: '#barTool' }
            ]
        ],
        page: {}
    });
});
</script>
{/block}